<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>元素的定时执行</title>
</head>
<body>
        <script>
           var i = 0;
           var s = 0;
          function foo() {
              i = i + 1;
                s = s + i;
              console.log(s);
              if(i>= 100){
                  clearInterval(timer)
              }
          }
              var timer =  setInterval(foo,100)
        </script>

</body>
</html>